15. Many-To-Many Relationships: Part I
Model many-to-many relationships Heading
Modeling a many-to-many relationship in SQLAlchemy ORM - Part 1
Types of relationships
ND004 C01 L07 14 Model Many-To-Many Relationships
Relationship Quiz
QUIZ QUESTION: :
See if you can match each of these examples with the correct relationship type.
ANSWER CHOICES:
Example |
What type of relationship? |
---|---|
One-to-one |
|
One-to-many |
|
One-to-one |
|
Many-to-many |
|
One-to-many |
|
Many-to-many |
SOLUTION:
Example |
What type of relationship? |
---|---|
One-to-one |
|
One-to-one |
|
One-to-many |
|
One-to-many |
|
One-to-one |
|
One-to-one |
|
Many-to-many |
|
One-to-many |
|
One-to-many |
|
Many-to-many |
Model many-to-many relationships Recap
Keys in relationships; association tables
ND004 C01 L07 14.1 Model Many-To-Many Relationships
Takeaways
- In one-to-many and one-to-one, the foreign key is established on the child model.
- In many-to-many, a special association table exists to join the two tables together, storing two foreign keys that link to the two foreign tables that have a relationship with each other.